package com.example.aigc_education.integration.response.workflows.v1;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Data;

import java.io.IOException;
import java.io.Serializable;

@Data
public class CozeAiTeacherResponse implements Serializable {

    // TODO: 优化：可能不是所有字段都要

//    @JsonProperty("content_type")
//    private Integer content_type;
//
//    @JsonDeserialize(using = AiTeacherDataDeserializer.class)
//    private AiTeacherData data;

    @JsonProperty("output")
    private String output;

//    @JsonProperty("original_result")
//    private Object original_result;
//
//    @JsonProperty("type_for_model")
//    private Integer type_for_model;

//    @Data
//    public static class AiTeacherData implements Serializable{
//        private String content;
//    }

//    public static class AiTeacherDataDeserializer extends JsonDeserializer<AiTeacherData> {
//
//        @Override
//        public AiTeacherData deserialize(JsonParser jsonParser, DeserializationContext Context) throws IOException, JacksonException {
//            ObjectMapper mapper = (ObjectMapper) jsonParser.getCodec();
//            JsonNode node = jsonParser.readValueAsTree();
//            CozeAiTeacherResponse.AiTeacherData aiTeacherResponse = new CozeAiTeacherResponse.AiTeacherData();
//
//            if (node.isTextual()) {
//                String jsonString = node.asText();
//                aiTeacherResponse = mapper.readValue(jsonString, mapper.getTypeFactory().constructType(CozeAiTeacherResponse.AiTeacherData.class));
//            }
//
//            return aiTeacherResponse;
//        }
//    }

}
